package com.tear.language.node;

import java.util.Map;

import net.sf.json.JSONObject;
import ognl.Ognl;

import org.apache.commons.lang.StringUtils;

import com.tear.language.utils.Attrs;

/**
返回结果节点
*/
public class ResultNode extends BaseNode {

	@Override
	public boolean parse(Map<String, Object> currParams,Map<String, Object> globalParams, JSONObject obj) throws Exception {
		
	//	String typeStr = ele.attributeValue("type");
		String valueStr = obj.optString(Attrs.VALUE);
		String nameStr = obj.optString("name");
		Map<String,Object> allParams = getAllParams(currParams, globalParams);
		if(StringUtils.isNotEmpty(valueStr)) {
			Object value = Ognl.getValue(valueStr, allParams);
			globalParams.put(Attrs.RESULT_FLAG, value);
		}
		if(StringUtils.isNotEmpty(nameStr)) {
			globalParams.put(nameStr, globalParams.get(Attrs.RESULT_FLAG));
		}
		return true;
	}

}
